<?php
session_start();

/**
 * Script used to determin wheter a user is logged in or not
 * Returns true or false in the response
 */

// Return json encoded data
header ('Content-type: application/json');

require_once '../core/db.php';

$sql = "SELECT * FROM siteUsers WHERE userID=:uid";
$query = $db -> prepare($sql);
if(!isset($_SESSION['user'])){
	die(json_encode(array("respond" => "false")));
}
$query -> bindParam(':uid', $_SESSION['user']);
$query -> execute();
$res = $query -> fetch();
if(isset($res['userName'])){
	die(json_encode(array("respond" => "true")));
}else{
	die(json_encode(array("respond" => "false")));
}